package org.biubiu0002.baiblog.im.concurrent;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 *
 * @Author: biubiu0002
 * @Date: 2022/8/30 23:32
 **/
public class FutureTaskScheduler {
    private static ThreadPoolExecutor threadPoolExecutor = null;
    static {
        ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("futureTask-%d").build();
        threadPoolExecutor = new ThreadPoolExecutor(4,8,30, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1000),threadFactory);
    }

    private FutureTaskScheduler(){}
    public static void add(Runnable executeTask){
        threadPoolExecutor.submit(executeTask);
    }
}
